package com.mxpio.erp.common.oa.entity;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.mxpio.erp.common.jpa.policy.ResCodeGeneratorPolicy;
import com.mxpioframework.jpa.annotation.Generator;
import com.mxpioframework.security.annotation.Dict;
import com.mxpioframework.security.entity.BaseEntity;
import com.mxpioframework.security.entity.Dept;
import com.mxpioframework.security.entity.User;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.springframework.format.annotation.DateTimeFormat;

import javax.persistence.*;
import java.util.Date;

@Data
@EqualsAndHashCode(callSuper=false)
@Entity
@Table(name = "MB_ERP_OA_LEAVE")
@Schema(description="请假单")
public class OaLeave extends BaseEntity {

    @Id
    @Column(name = "BIZ_NO_", updatable = false)
    @Generator(policy = ResCodeGeneratorPolicy.class)
    @Schema(description = "工单编号")
    private String bizNo;

    @Column(name = "EMPLOYEE_NAME_")
    @Schema(description = "员工工号")
    @Dict(dicCode="username", dicEntity = User.class, dicText = "nickname")
    private String employeeId;


    @Column(name = "DEPT_CODE_")
    @Schema(description = "部门编号")
    @Dict(dicCode="deptCode", dicEntity = Dept.class, dicText = "deptName")
    private String deptCode;

    @Column(name = "LEAVE_TYPE_")
    @Schema(description = "请假类型")
    @Dict(dicCode = "MB_ERP_OA_LEAVE_TYPE") //10事假 20病假 30年休假 40婚假 50产假 60丧假 70工伤假 80调休 90陪产假
    private String leaveType;

    @Column(name = "LEAVE_DAYS_")
    @Schema(description = "请假天数")
    private Integer leaveDays;

    @JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd")
    @DateTimeFormat(pattern="yyyy-MM-dd")
    @Column(name = "LEAVE_START_TIME_")
    @Schema(description = "请假开始时间")
    private Date leaveStartTime;

    @JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd")
    @DateTimeFormat(pattern="yyyy-MM-dd")
    @Column(name = "LEAVE_END_TIME_")
    @Schema(description = "请假结束时间")
    private Date leaveEndTime;

    @Column(name = "LEAVE_REASON_",columnDefinition = "TEXT")
    @Schema(description = "请假理由")
    private String leaveReason;

    @Column(name = "REPLACEMENT_WORKER_EMPLOYEE_NAME_")
    @Schema(description = "代岗人员工名称")
    @Dict(dicCode="username", dicEntity = User.class, dicText = "nickname")
    private String proxyWorkerEmployeeId;


    @JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd")
    @DateTimeFormat(pattern="yyyy-MM-dd")
    @Schema(description = "申请时间")
    @Column(name = "APPLY_TIME_")
    private Date applyTime;

    @Column(name = "ORDER_STATUS_")
    @Schema(description = "工单状态") //10新增 20审核中 30已完成 40已关闭
    @Dict(dicCode = "MB_ERP_OA_INVOICE_ORDER_STATUS")
    private String orderStatus;

    /**审批状态*/
    @Column(name = "BPMN_STATUS_")
    @Schema(description = "审批状态")
    @Dict(dicCode = "ERP_COMMON_BPMN_STATUS")
    private String bpmnStatus;

    /**审批实例ID*/
    @Column(name = "PROCESS_INSTANCE_ID_")
    @Schema(description = "审批实例ID")
    private String processInstanceId;

    @Transient
    @Schema(description = "是否撤销审批")
    @Dict(dicCode = "ERP_COMMON_YESNO") //0否 1是
    private String revoke;

    @Schema(description = "扩展字段")
    @Column(name = "FEATURE_")
    private String feature;

}
